package com.evil.application.api;

import com.evil.application.config.ApplicationFeignErrorDecoder;
import com.evil.application.pojo.dto.form.control.option.FormOptionRespDTO;
import com.evil.application.pojo.dto.reporting.data.RefreshAppOrderReqDTO;
import com.evil.common.application.dto.order.data.ControlDataDTO;
import com.evil.common.family.constant.ServiceNameConstant;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import jakarta.validation.constraints.NotEmpty;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * 应用订单数据服务
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@FeignClient(name = ServiceNameConstant.APPLICATION_SERVICE, configuration = {ApplicationFeignErrorDecoder.class})
public interface RemoteApplicationOrderDataService {

    // region es

    /**
     * 重建ES索引
     */
    @PostMapping("/remote/application/order/es/index/re-create")
    void reCreateESIndex();

    /**
     * 删除ES索引
     */
    @PostMapping("/remote/application/order/es/index/delete")
    void deleteESIndex();

    /**
     * 刷新ES订单
     *
     * @param orderId orderId
     */
    @PostMapping("/remote/application/order/refresh/es-order-id")
    void refreshEsOrderId(@RequestParam("orderId") Long orderId);

    /**
     * 刷新ES订单
     *
     * @param orderIds orderIds
     */
    @PostMapping("/remote/application/order/refresh/es-order-ids")
    void refreshEsOrderIds(@NotEmpty @RequestBody Collection<Long> orderIds);

    /**
     * 刷新ES订单
     *
     * @param refreshAppOrderReqDTO refreshAppOrderReqDTO
     */
    @PostMapping("/remote/application/order/refresh/es-orders")
    void refreshEsOrderIds(@RequestBody RefreshAppOrderReqDTO refreshAppOrderReqDTO);
    // endregion

    /**
     * 关联控件数据列表
     *
     * @param orderDataIds orderDataIds
     * @return List
     */
    @PostMapping("/remote/application/order/related-data-option")
    List<FormOptionRespDTO> orderRelatedSelect(Collection<Long> orderDataIds);

    /**
     * 关联控件数据Map
     *
     * @param orderDataIds orderDataIds
     * @return Map<orderDataId, FormOptionRespDTO>
     */
    @PostMapping("/remote/application/order/related-data-option-map")
    Map<Long, FormOptionRespDTO> orderRelatedSelectMap(Collection<Long> orderDataIds);

    /**
     * 订单数据
     *
     * @param orderId orderId
     * @return List
     */
    @PostMapping("/remote/application/order/data/list")
    List<ControlDataDTO> getOrderControlData(@RequestParam("orderId") Long orderId);
}
